package com.mo.global.utils.jsr;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Auther:Lang
 * @Date:2022-11-27
 * @Time:18:39
 * @Description:统一信息返回类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    //服务端返回的错误码
    private int code ;
    //服务端返回的错误信息
    private String msg ;
    //服务端返回的数据
    private T data;

    public static  <T> Result success(T data){
        Result<T> result = new Result<>(200, "success", data);
        return result;
    }

    public static  <T> Result success(String msg, T data){
       Result<T> result = new Result<>(200, msg, data);
        return result;
    }


    public static  <T> Result error(int code, String msg){
        Result<T> result = new Result<>(code, msg, null);
        return result;
    }
    public static  <T> Result error(int code, String msg, T data){
        Result<T> result = new Result<>(code, msg, data);
        return result;
    }

}
